<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="elibrary.DesEncrypter"%>
<%@ page import="elibrary.DaoConnection" %>
<%@ page language="java" import="java.util.*"%>
<%@ include file="config.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>My-Library | User Registration</title>
        <meta name="keywords" content="My Library" />
        <meta name="description" content="Library" />
        <link href="css/style.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="js/register.js"></script>
        <script language="javscript" type="text/javascript" src="js/jquery.min.js"></script>
    </head>
    <body><%

    // User is checked whether he is an administrator; if yes, he is allowed to register new users

     try
        {
    	
             //check if the admin is log in
	 
        String uid=(String)session.getAttribute("uid");
        if(uid==null||uid.equals(""))
        {
        response.sendRedirect("index.jsp");
        }
    
        //the type of the user is checked and if he is not an admin then he is sent back to his home page
    
        int type=Integer.parseInt((String)session.getAttribute("type"));
        if(type!=3)
        {
             response.sendRedirect("home.jsp");
        }
    
        //user id is encrypted here
    
        DesEncrypter encrypter = new DesEncrypter();
            int uid1 = Integer.parseInt(encrypter.decrypt(uid));
        Connection c=DaoConnection.getcon(connectURL, DBuser, DBpass);
        Statement st=c.createStatement();
        ResultSet rs=st.executeQuery("Select * from USERS WHERE UID="+uid1);
    
        rs.next();
        %>

        <%}catch(Exception e){e.printStackTrace();} %>
        <div id="templatemo_header_wrapper">

            <div id="templatemo_header">

                <div id="site_logo"><img src="images/logo.jpeg" width="100" height="100"></div><div align="left"><img src="images/header.png"></div>
            </div> <!-- end of header -->

        </div> <!-- end of header wrapper -->

        <div id="templatemo_menu_wrapper">

            <div id="templatemo_menu">
                <ul>
                    <li><a href="#" class="current">Home</a></li>
                    <li><a href="#">Web Design</a></li>
                    <li><a href="http://www.templatemo.com" target="_parent">Templates</a></li>
                    <li><a href="#">About</a></li>
                    <li><a href="#" class="last">Contact Us</a></li>
                </ul>
            </div> <!-- end of menu -->
        </div> <!-- end of menu wrapper -->

        <div id="tempatemo_content_wrapper">

            <div id="templatemo_content">

                <div class="content_top">

                </div>

                <div id="content_panel">

                    <div id="column_w610">
                        <% if (session.getAttribute("message") != null) { %>
                        <div id="msgbox">
                            <%= session.getAttribute("message") %>
                            <% session.setAttribute("message", null); %>
                        </div>
                        <%} %>
                        <form name="registration" action=userRegistrationProcess.jsp method="post" onsubmit="return validate()">
                            <table>
                                <tr>
                                    <td>Username</td>
                                    <td><input name="username" type="text" value="" size="25" maxlength="80" onkeyup="validateusername(this.value)"/></td>
                                    <td>
                                        <div id="ajaxbusy"><img src="images/ajaxbusy.gif"/></div>
                                        <span id="usernameDIV" ></span>
                                    </td>
                                </tr>
                                <tr>
                                    <td>Password</td>
                                    <td><input name="password" type="password" value="" size="25" maxlength="80" /></td>
                                </tr>
                                <tr>
                                    <td>First Name</td>
                                    <td><input name="fname" type="text" value="" size="25" maxlength="80" /></td>
                                </tr>
                                <tr>
                                    <td>Last Name</td>
                                    <td><input name="lname" type="text" value="" size="25" maxlength="80" /></td>
                                </tr>
                                <tr>
                                    <td>Email</td>
                                    <td><input name="email" type="text" value="" size="25" maxlength="80" /></td>
                                </tr>
                                <tr>
                                    <td>User Type</td>
                                    <td>
                                        <select name="type">
                                            <option value="1">Student / Faculty</option>
                                            <option value="2">Author / Publisher</option>
                                            <option value="3">Administrator</option>
                                        </select>
                                    </td>
                                </tr>

                                <tr>
                                    <td>
                                        <br />
                                        <input name="submit" type="submit" value="Register" />
                                    </td>
                                    <td>
                                        <br />
                                        <input name="reset" type="reset" value="Reset" />
                                    </td>
                                </tr>

                            </table>
                        </form>

                    </div> <!-- end of column w610 -->

                    <div id="column_w290">

                        <div class="header_02">News and Events</div>

                        <div class="news_section">
                            <div class="news_date">
                        	29 <span> OCT</span>
                            </div>
                            <div class="news_content">
                                <div class="header_05"><a href="#">Lorem ipsum dolor sit</a></div>
                                <p>Lorem ipsum dolor sit amet, cons ect etur adipiscing elit. Vestibu lum ac dui non tellus auctor.</p>
                            </div>

                            <div class="cleaner"></div>
                        </div>

                        <div class="news_section">
                            <div class="news_date">
                        	28 <span> OCT</span>
                            </div>
                            <div class="news_content">
                                <div class="header_05"><a href="#">Nam dictum pellentesque</a></div>
                                <p>Nam ultricies cursus enim, non aliquet orci lacinia ac. Etiam lobortis adipiscing convallis. </p>
                            </div>

                            <div class="cleaner"></div>
                        </div>

                        <div class="news_section">
                            <div class="news_date">
                        	27 <span> OCT</span>
                            </div>
                            <div class="news_content">
                                <div class="header_05"><a href="#">Donec faucibus tortor</a></div>
                                <p>Aliquam porttitor nibh in erat porttitor in accumsan dui pulvinar. Vivamus a sapien arcu.</p>
                            </div>

                            <div class="cleaner"></div>
                        </div>

                        <div class="header_02">Subscribe Newsletter</div>

                        <div class="column_w290_content">

                            <form action="#" method="get">
                                <input type="text" value="Please enter your email address" name="q" size="10" class="inputfield" title="email address" onfocus="clearText(this)" onblur="clearText(this)" />

                                <input type="submit" name="submit" value="Submit" alt="Search" class="submitbutton" title="submit" />
                            </form>

                        </div>
                    </div> <!-- end of column 290 -->

                    <div class="cleaner"></div>

                </div> <!-- end of content panel -->

                <div class="cleaner"></div>
            </div> <!-- end of content -->

        </div> <!-- end of content wrapper -->

        <div id="templatemo_footer_wrapper">

            <div id="templatemo_footer">

                <center>Copyright &#169; 2010 MyLibrary &nbsp &nbsp | &nbsp &nbsp <a href="termsandconditions.jsp"><font color="#828c96"> Terms and Conditions</font></a> </center><br></br>
                <center><b>Disclaimer:</b> No Part of this site can be copied or reproduced in any form, excepting for personal information, without the written permission of the owners.</center>
            </div> <!-- end of footer -->
        </div> <!-- end of footer -->
    </body>
</html>

